
/* ###############################################

		1. 작    성   일 	>> 	2007. 1. 29
	
		2. 파    일   명 	>> 	Client.cpp

 		3. 내          용 	>> 	Client Entity Class...( IpAddress, PSocket )
 		
 		4. 작   성    자 	>>	최철호
 		
 		5. 최종수정일	>>	2007. 1. 29
										
################################################ */


#include "Client.h"

Client::Client( string ipAddress )
: ipAddress( ipAddress ) 
{
	this->clientConnectSocket = 0;
}

Client::Client( string ipAddress, PSocket* clientConnectSocket )
: ipAddress( ipAddress ) 
{
	this->clientConnectSocket = clientConnectSocket;
}

Client::Client( const Client& source )
: ipAddress( source.ipAddress ) 
{
	if( source.clientConnectSocket != NULL )
	{
		this->clientConnectSocket = new PSocket( *(source.clientConnectSocket) );		
	}
	else
	{
		this->clientConnectSocket = NULL;
	}	
}

Client::~Client()
{
	if( this->clientConnectSocket != 0 )
	{
		delete this->clientConnectSocket;
	}
}
	
Client& Client::operator =( const Client& source )
{
	this->ipAddress = source.ipAddress;
	
	if( this->clientConnectSocket != 0 )
	{
		delete this->clientConnectSocket;
	}
	
	if( source.clientConnectSocket != NULL )
	{
		this->clientConnectSocket = new PSocket( *(source.clientConnectSocket) );		
	}
	else
	{
		this->clientConnectSocket = NULL;
	}	
	
	return (*this);
}

bool Client::operator==( const Client& other )
{
	bool ret = false;

	if( 	this->ipAddress == other.ipAddress &&
		*(this->clientConnectSocket) == *(other.clientConnectSocket) 	)		
	{
		ret = true;
	}

	return ret;	
}

bool Client::operator!=( const Client& other )
{
	bool ret = false;

	if( 	this->ipAddress != other.ipAddress ||
		*(this->clientConnectSocket) != *(other.clientConnectSocket) 	)		
	{
		ret = true;
	}

	return ret;	

}

